package jtk.project4.fleet.screen.addGeneralExpense;

/*
* Author : Rio Dermawan 
* Date Created : 1-April-2011
* Date Modified : 6-April-2011
* Version : 1.1
* */

import java.sql.SQLException;

import jtk.project4.fleet.FleetModel;
import jtk.project4.fleet.domain.MiscExp;
import jtk.project4.fleet.event.AddGeneralExpenseEvent;
import nl.coderight.jazz.Controller;

public class AddGeneralExpenseController extends Controller{
	private FleetModel fleetModel;
	private AddGeneralExpenseView addGeneralExpenseView;

	public void handleEvent(AddGeneralExpenseEvent evt) throws SQLException {
		MiscExp miscExp = fleetModel.getMiscExp();
		switch (evt.getType()) {
		case SAVE:
			System.out.println(miscExp.getNotes());
			fleetModel.insertMiscExp(miscExp);
			break;
		default:
			propagateEvent(evt);
			break;
		}
	}
	
	@Override
	public void execute() {
		fleetModel = (FleetModel) getModel();
		addGeneralExpenseView = new AddGeneralExpenseView();
		setView(addGeneralExpenseView);
		showView();
	}

}
